<template>
  <div class="container">
    <!-- form表单 -->
    <el-form ref="search" :inline="true" :model="formInline" class="search" label-width="100px" size="small">
      <el-form-item label="申报人:">
        <el-input v-model="formInline.user" placeholder="请输入名称" />
      </el-form-item>
      <el-form-item label="工单编号:">
        <el-input v-model="formInline.region" type="password" placeholder="请输入编号" />
      </el-form-item>
      <el-form-item label="时间:">
        <el-time-select v-model="startTime" placeholder="开始时间" :picker-options="{
            start: '08:30',
            step: '00:15',
            end: '18:30'
          }" size="mini" class="timeSelect" />
        <el-time-select v-model="endTime" placeholder="结束时间" :picker-options="{
            start: '08:30',
            step: '00:15',
            end: '18:30',
            minTime: startTime
          }" size="mini" class="timeSelect" />
      </el-form-item>
      <el-form-item label="工单状态:">
        <el-select v-model="formInline.region" placeholder="请选择工单状态">
          <el-option label="已取消" value="shanghai" />
          <el-option label="待结单" value="beijing" />
          <el-option label="待分派" value="beijing" />
          <el-option label="处理中" value="beijing" />
          <el-option label="待处理" value="beijing" />
          <el-option label="已完成" value="beijing" />
        </el-select>
      </el-form-item>
      <el-form-item label="事件来源:">
        <el-select v-model="formInline.region" placeholder="请选择事件来源">
          <el-option label="平台工单" value="shanghai" />
          <el-option label="app工单" value="beijing" />
        </el-select>
      </el-form-item>
      <el-form-item class="cha">
        <el-button type="primary" size="mini" @click="onSubmit">查询</el-button>
        <el-button type="info" size="mini" @click="onSubmit">重置</el-button>
      </el-form-item>
    </el-form>
    <!-- 表格 -->
    <div class="table-wrap">
      <div class="f-betweenX table-header">
        <div class="table-title">
          <svg-icon icon-class="table_menu" class-name="icon-table" />
          查询结果 共找到 <span class="count">1006</span> 条符合的记录{{ maxTableHeight }}
        </div>
        <div class="table-control">
          <el-button type="primary" size="mini" icon="el-icon-plus" plain @click="handleAdd">
            新建工单
          </el-button>
        </div>
      </div>
      <el-table :data="tableData" border style="width: 100%">
        <el-table-column fixed type="index" label="序号" width="50" />
        <el-table-column prop="date" label="工单编号" />
        <el-table-column prop="name" label="报修描述" />
        <el-table-column prop="address" label="申报人" />
        <el-table-column prop="address" label="工单状态" />
        <el-table-column prop="address" label="资产编号" />
        <el-table-column prop="address" label="资产名称" />
        <el-table-column prop="address" label="事件来源" />
        <el-table-column prop="address" label="创建时间" />
        <el-table-column prop="address" label="指派人" />
        <el-table-column prop="address" label="处理时间" />
        <el-table-column label="操作" align="center" fixed="right" width="300px">
          <template slot-scope="scope">
            <el-button size="mini" type="warning" icon="el-icon-check" plain @click="handlereceiving(scope.$index, scope.row)">接单</el-button>
            <el-button size="mini" type="primary" icon="el-icon-search" plain @click="handleSees(scope.$index, scope.row)">查看</el-button>
            <el-button size="mini" type="info" icon="el-icon-edit" plain @click="handleHandle(scope.$index, scope.row)">处理</el-button>
          </template>
        </el-table-column>
      </el-table>
    </div>
    <!-- 分页组件 -->
    <Pagination />
    <!-- 接单组件 -->
    <Receiving ref="receiving" />
    <!-- 查看组件 -->
    <Handle ref="handle" />
    <Sees ref="sees" />
  </div>
</template>

<script>
// 巡检任务
import Pagination from './Pagination.vue'
import tableHeight from '@/mixins/tableHeight'
import Receiving from './receiving.vue'
import Handle from './handle.vue'
import Sees from './sees.vue'

export default {
  components: {
    Pagination,
    Receiving,
    Handle,
    Sees
  },
  mixins: [tableHeight],
  data () {
    return {
      tableData: [{
        date: '2016-05-02',
        name: '王小虎',
        address: '上海市普陀区金沙江路 1518 弄'
      }, {
        date: '2016-05-04',
        name: '王小虎',
        address: '上海市普陀区金沙江路 1517 弄'
      }, {
        date: '2016-05-01',
        name: '王小虎',
        address: '上海市普陀区金沙江路 1519 弄'
      }, {
        date: '2016-05-03',
        name: '王小虎',
        address: '上海市普陀区金沙江路 1516 弄'
      }, {
        date: '2016-05-03',
        name: '王小虎',
        address: '上海市普陀区金沙江路 1516 弄'
      }, {
        date: '2016-05-03',
        name: '王小虎',
        address: '上海市普陀区金沙江路 1516 弄'
      }, {
        date: '2016-05-03',
        name: '王小虎',
        address: '上海市普陀区金沙江路 1516 弄'
      }, {
        date: '2016-05-03',
        name: '王小虎',
        address: '上海市普陀区金沙江路 1516 弄'
      }, {
        date: '2016-05-03',
        name: '王小虎',
        address: '上海市普陀区金沙江路 1516 弄'
      }, {
        date: '2016-05-03',
        name: '王小虎',
        address: '上海市普陀区金沙江路 1516 弄'
      }],
      formInline: {
        user: '',
        region: '',
        deptId: []
      },
      startTime: '',
      endTime: ''
    }
  },
  methods: {
    // 新建工单
    handleAdd () {
      this.$router.push({ name: 'OrderRoute' })
    },
    // 接单
    handlereceiving () {
      this.$refs.receiving.toggleRece(true)
    },
    // 处理
    handleHandle () {
      this.$refs.handle.togglePopup(true)
    },
    // 查看
    handleSees () {
      this.$refs.sees.toggleSees(true)
    }
  }
}
</script>

<style lang="scss" scoped>
.container {
  padding: 0 17px;
  .cha {
    margin-left: 30px;
  }
  .search {
    padding-top: 16px;
  }
  .table-wrap {
    .icon-table {
      margin: 0 10px;
    }
    .table-header {
      height: 52px;
      background: #f6f7f9;
      border: 1px solid #e1e7e9;
      border-bottom: none;
      font-size: 16px;
      color: #494949;
      line-height: 52px;
      border-radius: 4px 4px 0 0;
      .count {
        color: rgb(235, 104, 84);
      }
      .table-control {
        margin-right: 10px;
      }
    }
  }
  .pagination-wrap {
    height: 80px;
    .pagination {
      display: inline-block;
    }
  }
  .timeSelect {
    width: 170px;
    margin-right: 5px;
  }
}
</style>

<style lang="scss">
.tree-line {
  .el-tree-node {
    position: relative;
    padding-left: 16px; // 缩进量
  }
  .el-tree-node__children {
    padding-left: 16px; // 缩进量
  }

  // 竖线
  .el-tree-node::before {
    content: '';
    height: 100%;
    width: 1px;
    position: absolute;
    left: -3px;
    top: -26px;
    border-width: 1px;
    border-left: 1px dashed #52627c;
  }
  // 当前层最后一个节点的竖线高度固定
  .el-tree-node:last-child::before {
    height: 38px; // 可以自己调节到合适数值
  }

  // 横线
  .el-tree-node::after {
    content: '';
    width: 24px;
    height: 20px;
    position: absolute;
    left: -3px;
    top: 12px;
    border-width: 1px;
    border-top: 1px dashed #52627c;
  }

  // 去掉最顶层的虚线，放最下面样式才不会被上面的覆盖了
  & > .el-tree-node::after {
    border-top: none;
  }
  & > .el-tree-node::before {
    border-left: none;
  }

  // 展开关闭的icon
  .el-tree-node__expand-icon {
    font-size: 16px;
    // 叶子节点（无子节点）
    &.is-leaf {
      color: transparent;
      // display: none; // 也可以去掉
    }
  }
}
</style>
